<!-- include tpl=head -->
<link rel="stylesheet" type="text/css" href="js/codemirror/codemirror.css" />
<script type="text/javascript" src="js/codemirror/codemirror.js"></script>
<style type="text/css">
.CodeMirror{border:1px solid #ccc;}
.CodeMirror-scroll{width:300px;height:60px;}
</style>
<script type="text/javascript">
function save()
{
	var obj = $.dialog.opener;
	$("#postsumbit").ajaxSubmit({
		'url':'{url ctrl=plugin func=exec id=collection exec=field_save tid=$tid fid=$fid/}',
		'type':'post',
		'dataType':'json',
		'success':function(rs){
			if(rs.status == 'ok'){
				$.dialog.alert("{$fid ? '字段修改成功' : '字段添加成功'}",function(){
					obj.$.phpok.reload();
				},'succeed');				
			}else{
				$.dialog.alert(rs.content);
				return false;
			}
		}
	});
}
</script>
<form method="post" id="postsumbit">
<div class="table">
	<table>
	<tr>
		<td>标签名：</td>
		<td><input type="text" name="title" id="title" value="{$rs.title}" class="long"></td>
	</tr>
	</table>
</div>

<div class="table">
	<table>
	<tr>
		<td>变量名：</td>
		<td><input type="text" name="identifier" id="identifier" value="{$rs.identifier}" class="long"></td>
	</tr>
	</table>
</div>
<script type="text/javascript">
function action_tags_type(val)
{
	if(val == 'string'){
		$("#collection_string").show();
		$("#collection_var").hide();
	}else{
		$("#collection_string").hide();
		$("#collection_var").show();
	}
}
</script>
<div class="table">
	<div class="content">
		<table cellspacing="0" cellpadding="0">
		<tr>
			<td>标签类型：</td>
			<td>
				<ul class="layout">
					<li><label><input type="radio" name="tags_type" value="var"{if !$rs || $rs.tags_type == 'var'} checked{/if} onclick="action_tags_type(this.value)" />变量</label></li>
					<li><label><input type="radio" name="tags_type" value="string"{if $rs.tags_type == 'string'} checked{/if} onclick="action_tags_type(this.value)" />固定值</label></li>
				</ul>
			</td>
		</tr>
		</table>
	</div>
</div>

<div id="collection_string"{if !$rs || $rs.tags_type != 'string'} class="hide"{/if}>
	<div class="table">
		<div class="title">固定值：<span class="note">当标签为固定值时，需要在这里设置内容</span></div>
		<div class="content"><input type="text" name="rules" id="rules" value="{$rs.rules}" class="long"/></div>
		
	</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
	var c_rules_start = CodeMirror.fromTextArea(document.getElementById("rules_start"),{
		lineNumbers		: true,
		matchBrackets	: true,
		lineWrapping	: true,
		indentWithTabs	: true,
		indentUnit		: 4,
		onChange		: function(n){
			$("#rules_start").val(c_rules_start.getValue());
		}
	});
	var c_rules_end = CodeMirror.fromTextArea(document.getElementById("rules_end"),{
		lineNumbers		: true,
		matchBrackets	: true,
		lineWrapping	: true,
		indentWithTabs	: true,
		indentUnit		: 4,
		onChange		: function(n){
			$("#rules_end").val(c_rules_end.getValue());
		}
	});
	var c_suburl_start = CodeMirror.fromTextArea(document.getElementById("suburl_start"),{
		lineNumbers		: true,
		matchBrackets	: true,
		lineWrapping	: true,
		indentWithTabs	: true,
		indentUnit		: 4,
		onChange		: function(n){
			$("#suburl_start").val(c_suburl_start.getValue());
		}
	});
	var c_suburl_end = CodeMirror.fromTextArea(document.getElementById("suburl_end"),{
		lineNumbers		: true,
		matchBrackets	: true,
		lineWrapping	: true,
		indentWithTabs	: true,
		indentUnit		: 4,
		onChange		: function(n){
			$("#suburl_end").val(c_suburl_end.getValue());
		}
	});
});
</script>
<div id="collection_var"{if $rs && $rs.tags_type == 'string'} class="hide"{/if}>
	<div class="table">
		<table>
		<tr>
			<td>开始字符串：<span class="red">(*)</span></td>
			<td>结束字符串：<span class="red">(*)</span></td>
		</tr>
		<tr>
			<td><textarea name="rules_start" id="rules_start" style="width:300px;height:60px;max-width:300px;">{$rs.rules_start}</textarea></td>
			<td><textarea name="rules_end" id="rules_end" style="width:300px;height:60px;max-width:300px;">{$rs.rules_end}</textarea></td>
		</tr>
		</table>
	</div>


	<div class="table">
		<div class="content">
			<table cellspacing="0" cellpadding="0">
			<tr>
				<td>HTML标签过滤：</td>
				<td>
					<ul class="layout">
						<li><label><input type="checkbox" id="del_url" name="del_url"{if $rs.del_url} checked{/if} />链接</label></li>
						<li><label><input type="checkbox" id="del_font" name="del_font"{if $rs.del_font} checked{/if} />字体</label></li>
						<li><label><input type="checkbox" id="del_table" name="del_table"{if $rs.del_table} checked{/if} />表格</label></li>
						<li><label><input type="checkbox" id="del_span" name="del_span"{if $rs.del_span} checked{/if} />Span标签</label></li>
						<li><label><input type="checkbox" id="del_bold" name="del_bold"{if $rs.del_bold} checked{/if} />加粗</label></li>
						<li><label><input type="checkbox" id="del_html" name="del_html"{if $rs.del_html} checked{/if} />所有HTML代码</label></li>
					</ul>
				</td>
			</tr>
			</table>
			
		</div>
	</div>

	<div class="table">
		<div class="title">内容排除：<span class="note">一行一条排除记录，支持多行，支持 <span class="red">(*)</span>，要使用替换，请使用<span class="red">[:phpok:]</span>分隔！</span></div>
		<div class="content"><textarea id="del" name="del" style="width:530px;height:60px;max-width:530px;">{$rs.del}</textarea></div>
	</div>

	<div class="table">
		<div class="title">分页设置：<span class="note">当前采集功能仅识别链接格式的分页，需要更强大的采集功能建议使用第三方采集器</span></div>
		<table>
		<tr>
			<td>开始：支持<span class="red">(*)</span></td>
			<td>结束：支持<span class="red">(*)</span></td>
		</tr>
		<tr>
			<td><textarea id="suburl_start" name="suburl_start" style="width:300px;height:50px;max-width:300px;" >{$rs.suburl_start}</textarea></td>
			<td><textarea id="suburl_end" name="suburl_end" style="width:300px;height:50px;max-width:300px;" >{$rs.suburl_end}</textarea></td>
		</tr>
		</table>
	</div>
	<div class="table">
		<table>
		<tr>
			<td>发布格式化：</td>
			<td>
				<select name="post_save" id="post_save">
					<option value="safe">实体HTML</option>
					<option value="safe_cut"{if $rs.post_save == 'safe_cut'} selected{/if}>文本只保留80字</option>
					<option value="html"{if $rs.post_save == 'html'} selected{/if}>HTML发布</option>
					<option value="int"{if $rs.post_save == 'int'} selected{/if}>整数型发布</option>
					<option value="float"{if $rs.post_save == 'float'} selected{/if}>浮点型发布，适用价格</option>
					<option value="datetime"{if $rs.post_save == 'datetime'} selected{/if}>将文本格式化为时间戳</option>
					<option value="img"{if $rs.post_save == 'img'} selected{/if}>只提取图片存储【注意必须启用缩略图和多图功能】</option>
				</select>
			</td>
		</tr>
		</table>
	</div>
	<!-- if $plugin.collection.param.keyfrom && $plugin.collection.param.keyid -->
	<div class="table">
		<table>
		<tr>
			<td>翻译：</td>
			<td>
				<select name="translate" id="translate">
					<option value="0">不翻译</option>
					<option value="1"{if $rs.translate == 1} selected{/if}>中英互译</option>
					<option value="2"{if $rs.translate == 2} selected{/if}>繁体转简体</option>
				</select>
			</td>
			<td>原文：</td>
			<td>
				<ul class="layout">
					<li><label><input type="radio" name="re1" value="0"{if !$rs.re1} checked{/if} />不保留</label></li>
					<li><label><input type="radio" name="re1" value="1"{if $rs.re1} checked{/if} />保留</label></li>
				</ul>
			</td>
		</tr>
		</table>
	</div>
	<!-- /if -->

</div>

</form>
<!-- include tpl=foot_open -->